<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
    <el-form-item label="积分" prop="integral">
      <el-input v-model="dataForm.integral" placeholder="积分"></el-input>
    </el-form-item>
    <el-form-item label="余额" prop="balace">
      <el-input v-model="dataForm.balace" placeholder="余额"></el-input>
    </el-form-item>
    <el-form-item label="累计消费" prop="totalConsume">
      <el-input v-model="dataForm.totalConsume" placeholder="累计消费"></el-input>
    </el-form-item>
    <el-form-item label="更新日期" prop="updateTime">
      <el-input v-model="dataForm.updateTime" placeholder="更新日期"></el-input>
    </el-form-item>
    <el-form-item label="更新人" prop="updateMan">
      <el-input v-model="dataForm.updateMan" placeholder="更新人"></el-input>
    </el-form-item>
    <el-form-item label="备注" prop="remark">
      <el-input v-model="dataForm.remark" placeholder="备注"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()" :disabled="disabledSubmit">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          memberId: 0,
          integral: '',
          balace: '',
          totalConsume: '',
          updateTime: '',
          updateMan: '',
          remark: ''
        },
        dataRule: {
          integral: [
            { required: true, message: '积分不能为空', trigger: 'blur' }
          ],
          balace: [
            { required: true, message: '余额不能为空', trigger: 'blur' }
          ],
          totalConsume: [
            { required: true, message: '累计消费不能为空', trigger: 'blur' }
          ],
          updateTime: [
            { required: true, message: '更新日期不能为空', trigger: 'blur' }
          ],
          updateMan: [
            { required: true, message: '更新人不能为空', trigger: 'blur' }
          ],
          remark: [
            { required: true, message: '备注不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init (id) {
        this.dataForm.memberId = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.memberId) {
            this.$http({
              url: this.$http.adornUrl(`/store/tstorememberaccountdetail/info/${this.dataForm.memberId}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.integral = data.tStoreMemberAccountDetail.integral
                this.dataForm.balace = data.tStoreMemberAccountDetail.balace
                this.dataForm.totalConsume = data.tStoreMemberAccountDetail.totalConsume
                this.dataForm.updateTime = data.tStoreMemberAccountDetail.updateTime
                this.dataForm.updateMan = data.tStoreMemberAccountDetail.updateMan
                this.dataForm.remark = data.tStoreMemberAccountDetail.remark
              }
            })
          }
        })
      },
    }
  }
</script>
